CMAKE_MINIMUM_REQUIRED(VERSION 2.6)

#project name
PROJECT(LogPublisherSample)

set(CMAKE_CXX_FLAGS "-g -Wall")
#introot definition
SET(INTROOT $ENV{INTROOT})
IF(NOT INTROOT)
    SET(INTROOT $ENV{SWROOT})
    SET(SWROOT $ENV{SWROOT})
    IF(NOT SWROOT)
        SET(CMAKE_INSTALL_PREFIX="/tmp/Logger")
        MESSAGE("Nor INTROOT neither SWROOT defined, CMAKE_INSTALL_PREFIX set to: /tmp/Logger")
    ELSE(NOT SWROOT) 
        SET(CMAKE_INSTALL_PREFIX ${SWROOT})
        MESSAGE("No INTROOT defined. Using SWROOT, CMAKE_INSTALL_PREFIX set to: $ENV{SWROOT}")
    ENDIF(NOT SWROOT)
ELSE(NOT INTROOT)
    SET(CMAKE_INSTALL_PREFIX ${INTROOT})
    MESSAGE("CMAKE_INSTALL_PREFIX set to: $ENV{INTROOT}")
ENDIF(NOT INTROOT)
SET(LCU $ENV{TYPE})

IF(LCU)
    ADD_DEFINITIONS(-DLCU -DICEE_PURE_CLIENT)
ENDIF(LCU)

#SET_TARGET_PROPERTIES(publisherT PROPERTIES LINKER_LANGUAGE CXX)
#for .h file search
INCLUDE_DIRECTORIES(/usr/lib/include)
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/../include")
INCLUDE_DIRECTORIES("${INTROOT}/include")
INCLUDE_DIRECTORIES("$ENV{SWROOT}/include")
LINK_DIRECTORIES(${INTROOT}/lib $ENV{SWROOT}/lib)

ADD_EXECUTABLE(publisherT publisherTest)


IF(NOT LCU)
    TARGET_LINK_LIBRARIES(publisherT LoggerCore Ice)
ELSE(NOT LCU)
    TARGET_LINK_LIBRARIES(publisherT LoggerCore IceE)
ENDIF(NOT LCU)

#for make install
INSTALL(TARGETS publisherT
    RUNTIME DESTINATION ${INTROOT}/bin
    LIBRARY DESTINATION ${INTROOT}/lib
    ARCHIVE DESTINATION ${INTROOT}/lib
)

INSTALL(
   DIRECTORY ${PROJECT_SOURCE_DIR}/../idl/ DESTINATION ${INTROOT}/idl 
   FILES_MATCHING PATTERN "*.ice"
)

INSTALL(
   DIRECTORY ${PROJECT_SOURCE_DIR}/../include/ DESTINATION  ${INTROOT}/include 
   FILES_MATCHING PATTERN "*.h"
)


